var _tools = require("../../../utils/tools.js"), _tools2 = _interopRequireDefault(_tools);

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var that, app = getApp();

Page({
    data: {
        page: 1,
        isover: !1,
        pdd_keyword: "",
        top_h: 62
    },
    onLoad: function(t) {
        (that = this).setData({
            top_h: app.globalData.nav_height ? app.globalData.nav_height : 62
        });
    },
    inputText: function(t) {
        that.setData({
            pdd_keyword: t.detail.value
        });
    },
    clearInput: function() {
        that.setData({
            pdd_keyword: ""
        });
    },
    search_btn: function() {
        this.setData({
            isover: !1,
            pddGoodsList: [],
            page: 1
        }), that.loadGoods();
    },
    nav_sarc: function(t) {
        var a = t.currentTarget.dataset.contents;
        that.setData({
            pdd_keyword: a,
            isover: !1,
            pddGoodsList: [],
            page: 1
        }), that.loadGoods();
    },
    click_nav_det: function(t) {
        var a = t.currentTarget.dataset.goods_id;
        wx.navigateTo({
            url: "/bh_rising/pages/pdd_details/pdd_details?goods_id=" + a
        });
    },
    loadGoods: function() {
        var t = {
            action: "goods",
            contr: "pdd",
            token: wx.getStorageSync("token"),
            page: that.data.page,
            pdd_keyword: this.data.pdd_keyword
        };
        _tools2.default.request(t, function(t) {
            var a = t.info.pddGoodsList;
            1 < that.data.page && (a = that.data.pddGoodsList.concat(a)), that.setData({
                pddGoodsList: a
            }), t.info.pddGoodsList < 10 && that.setData({
                isover: !0
            });
        });
    },
    onReachBottom: function() {
        this.data.isover || (this.data.page++, this.loadGoods());
    },
    onReady: function() {
        wx.createSelectorQuery().select("#global-nav").boundingClientRect(function(t) {
            that.setData({
                m_height: t.height
            });
        }).exec();
        var t = {
            action: "popular",
            contr: "pdd",
            token: wx.getStorageSync("token")
        };
        _tools2.default.request(t, function(t) {
            that.setData(t.info);
        });
    },
    onShow: function() {},
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_cat/pages/index/index?parent_id=" + this.data.share.member_id
        };
    }
});